//
//  HMNewsCell.m
//  weiboOC
//
//  Created by 刘耀宗 on 16/4/11.
//  Copyright © 2016年 刘耀宗. All rights reserved.
//

#import "HMNewsCell.h"
#import <Masonry.h>
@interface HMNewsCell ()
@property (nonatomic, strong) UIImageView *cellImageView;


@end

@implementation HMNewsCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        [self setup];
    }
    return self;
}

-(void)setup
{
    UIImageView *cellImagaView=[[UIImageView alloc] init];
    [self.contentView addSubview:cellImagaView];
    self.cellImageView=cellImagaView;
    
    UIButton *Newsbtn=[[UIButton alloc] init];
    [self.contentView addSubview:Newsbtn];
    self.Newsbtn=Newsbtn;
    [self.Newsbtn setTitle:@"开始体验" forState:UIControlStateNormal];
    [self.Newsbtn setBackgroundImage:[UIImage imageNamed:@"new_feature_finish_button"] forState:UIControlStateNormal];
    [self.Newsbtn setBackgroundImage:[UIImage imageNamed:@"new_feature_finish_button_highlighted"] forState:UIControlStateHighlighted];
    self.Newsbtn.titleLabel.font=[UIFont systemFontOfSize:18];
    [self.Newsbtn.titleLabel sizeToFit];
    [self.Newsbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.Newsbtn.hidden=YES;

    
    



}
-(void)setIndex:(NSInteger)index
{
    _index= index;
//    if (self.Newsbtn.hidden==NO) {
//        self.Newsbtn.hidden=NO;
//    }
//    
    //拼接名字
    NSString *imageName=[NSString stringWithFormat:@"new_feature_%ld",index+1];
    self.cellImageView.image=[UIImage imageNamed:imageName];
    [self prepareFraeme];
    


}
-(void)prepareFraeme
{
    //使用bounds
    self.cellImageView.frame= self.bounds;
    CGFloat X= [UIScreen mainScreen].bounds.size.width*0.5-self.Newsbtn.titleLabel.frame.size.width*0.5;
    [self.Newsbtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(40);
        make.top.equalTo(self).offset(450);
        make.left.equalTo(self).offset(X);
        
        
    }];
   
  
}
-(void)layoutSubviews
{
    [super layoutSubviews];
   

}

@end
